package com.fzg.controller;


import com.fzg.common.enums.ResponseWrapper;
import com.fzg.common.model.enterprise.param.*;
import com.fzg.service.EnterpriseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 企业表 前端控制器
 * </p>
 *
 * @author fzg
 * @since 2021-12-13
 */
@RestController
@RequestMapping("/enterprise")
public class EnterpriseController {

    @Autowired
    private EnterpriseService enterpriseService;

    /**
     * 获取企业列表
     * @param param 参数类
     * @return ResponseWrapper
     */
    @GetMapping("/getEnterpriseList")
    public ResponseWrapper getEnterpriseList(@Validated GetEnterpriseListParam param){
        return enterpriseService.getEnterpriseList(param);
    }

    /**
     * // 获取企业列表(前端展示所有企业)
     * @return ResponseWrapper
     */
    @GetMapping("/getCompanyList")
    public ResponseWrapper getCompanyList(){
        return enterpriseService.getCompanyList();
    }

    /**
     * 检验企业账号是否相同
     */
    @GetMapping("/checkAccount")
    public ResponseWrapper checkAccount(@Validated CheckAccountParam param){
        return enterpriseService.checkAccount(param);
    }

    /**
     * 检验企业联系电话是否相同
     */
    @GetMapping("/checkPhone")
    public ResponseWrapper checkPhone(@Validated CheckEnterprisePhoneParam param){
        return enterpriseService.checkPhone(param);
    }

    /**
     * 检验当前登陆企业修改的企业联系电话是否已经存在
     */
    @GetMapping("/checkPhoneExistApi")
    public ResponseWrapper checkPhoneExistApi(@Validated CheckPhoneExistApiParam param){
        return enterpriseService.checkPhoneExistApi(param);
    }

    /**
     * 添加或编辑企业
     */
    @PostMapping("/addOrEditEnterprise")
    public ResponseWrapper addOrEditEnterprise(@Validated @RequestBody AddOrEditEnterpriseParam param){
        return enterpriseService.addOrEditEnterprise(param);
    }

    /**
     * 删除企业
     */
    @PostMapping("/delEnterprise")
    public ResponseWrapper delEnterprise(@Validated @RequestBody DelEnterpriseParam param){
        return enterpriseService.delEnterprise(param);
    }

    /**
     * 通过企业账号查询企业全部信息
     */
    @GetMapping("/getLoginCompanyInfo")
    public ResponseWrapper getCompanyInfoByAccount(@Validated GetCompanyInfoByAccountParam param){
        return enterpriseService.getCompanyInfoByAccount(param);
    }

    /**
     * 获取所有企业
     */
    @GetMapping("/getAllCompany")
    public ResponseWrapper getAllCompany(){
        return enterpriseService.getAllCompany();
    }

    /**
     * 当前登陆的企业修改自己信息
     */
    @PostMapping("/updateCompanyInfo")
    public ResponseWrapper updateCompanyInfo(@Validated @RequestBody UpdateCompanyInfoParam param){
        return enterpriseService.updateCompanyInfo(param);
    }

    /**
     * 获取公司的评价列表
     */
    @GetMapping("/getCompanyEvaluateList")
    public ResponseWrapper getCompanyEvaluateList(@Validated GetCompanyEvaluateListParam param){
        return enterpriseService.getCompanyEvaluateList(param);
    }

    /**
     * 提交评论
     */
    @PostMapping("/submitEvaluation")
    public ResponseWrapper submitEvaluation(@Validated @RequestBody SubmitEvaluationParam param){
        return enterpriseService.submitEvaluation(param);
    }


}
